<#assign base=request.contextPath>
<!DOCTYPE html> 
<html>
	<head>
		<title>${title}</title>
		<meta charset="utf-8">
		<#include "common/reference.ftl" />
		<#include "common/ligerui.ftl" />
		<#include "common/am.reference.ftl" />
        <script type="text/javascript" src="https://api.map.baidu.com/api?v=2.0&ak=m2NXDdtzhhZFjUe0OiH2MANKHphn76xF&s=1"></script>
	</head>
	<body class="${configs["skinName"]}">
		<div class="page-content">
			<div class="row">
			<#if viewMode !="view">
			<#include "common/breadcrumb.ftl">
			</#if>
				<form id="form" role="form" class="form-horizontal" method="post" action="${base}/${form_action}">
					<div class="col-xs-12">
						<div class="widget-box">
							<div class="widget-body">
								<input type="hidden" name="roadId" id="roadId" value="${model.roadId}" <#if viewMode == "view">disabled</#if>>
								<#if viewMode == "view">
								<div class="widget-header widget-header-flat">
									<h5 class="lighter">
										${module}
									</h5>
								</div>
								<#else>
								<div class="alert alert-warning">
									<strong>提示!</strong>
									<strong style="color:#dd514c;">出现红框</strong>的表示不能为空
								</div>
								</#if>
								<div class="form-group">
									<label class="col-sm-3 control-label no-padding-right">
										所属服务业务
									</label>
									<div class="col-sm-6">
										<select id="serviceCode" name="serviceCode" class="chosen-select form-control" required data-placeholder="请选择服务业务" <#if viewMode == "view">disabled</#if>>
											<#if serviceList?exists && serviceList?size gt 0>
											<#list serviceList as item>
											<option value="${item.serviceCode}"<#if model.serviceCode == item.serviceCode>selected</#if> >${item.serviceName}</option>
											</#list>
											</#if>
										</select>
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-3 control-label no-padding-right">
										路线名称
									</label>
									<div class="col-sm-6">
										<input type="text" id="roadName" name="roadName" value="${model.roadName}" class="form-control" required placeholder="请输入路线名称" <#if viewMode == "view">disabled</#if>>
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-3 control-label no-padding-right">
										起点地区
									</label>
									<div class="col-sm-6">
										<input id="txtStartRegionId" class="form-control" type="text" placeholder="请选择地区" value="" required <#if viewMode == "view">disabled</#if> />
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-3 control-label no-padding-right">
										起点地址
									</label>
									<div class="col-sm-6">
										<input type="hidden" id="startLon" name="startLon" value="${model.startLon}">
										<input type="hidden" id="startLat" name="startLat" value="${model.startLat}">
										<input id="startName" name="startName" class="form-control" type="text" placeholder="请选择在地图上点击选择地址" value="${model.startName}" required <#if viewMode == "view">disabled</#if> />
										<#if viewMode != 'view'>
										<div id="startMap" style="height:300px; width:100%"></div>
										</#if>
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-3 control-label no-padding-right">
										目的地地区
									</label>
									<div class="col-sm-6">
										<input id="txtEndRegionId" class="form-control" type="text" placeholder="请选择地区" value="" required <#if viewMode == "view">disabled</#if> />
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-3 control-label no-padding-right">
										目的地
									</label>
									<div class="col-sm-6">
										<input type="hidden" id="endLon" name="endLon" value="${model.endLon}">
										<input type="hidden" id="endLat" name="endLat" value="${model.endLat}">
										<input id="endName" name="endName" class="form-control" type="text" placeholder="请选择在地图上点击选择地址" value="${model.endName}" required <#if viewMode == "view">disabled</#if> />
										<#if viewMode != 'view'>
										<div id="endMap" style="height:300px; width:100%"></div>
										</#if>
									</div>
								</div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label no-padding-right">
                                        基础里程(km)
                                    </label>
                                    <div class="col-sm-6">
                                        <input id="mileage" name="mileage" class="form-control js-pattern-number" type="text" value="${model.mileage}" required min="0" <#if viewMode == "view">disabled</#if> />
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label no-padding-right">
                                        基础价格(元)
                                    </label>
                                    <div class="col-sm-6">
                                        <input id="price" name="price" class="form-control js-pattern-number" type="text" value="${model.price}" required min="0" <#if viewMode == "view">disabled</#if> />
                                    </div>
                                </div>

								<div class="form-group">
									<label class="col-sm-3 control-label no-padding-right">
                                        超出基础里程后单价(元/公里)
									</label>
									<div class="col-sm-6">
										<input id="kmPrice" name="kmPrice" class="form-control js-pattern-number" type="text" value="${model.kmPrice}" required min="0" <#if viewMode == "view">disabled</#if> />
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-3 control-label no-padding-right">
										公司收费比例
									</label>
									<div class="col-sm-6">
										<div class="input-group">
											<input id="chargeRatio" name="chargeRatio" class="form-control js-pattern-number" type="text" value="${model.chargeRatio}" required min="0" max="100" <#if viewMode == "view">disabled</#if> />
											<span class="input-group-addon">%</span>
										</div>
									</div>
								</div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label no-padding-right">
                                        分公司收费比例
                                    </label>
                                    <div class="col-sm-6">
                                        <div class="input-group">
                                            <input id="chargeRatio" name="subChargeRatio" class="form-control js-pattern-number" type="text" value="${model.subChargeRatio}" required min="0" max="100" <#if viewMode == "view">disabled</#if> />
                                            <span class="input-group-addon">%</span>
                                        </div>
                                    </div>
                                </div>
								<div class="form-group">
									<label class="col-sm-3 control-label no-padding-right">
										是否启用
									</label>
									<div class="col-sm-6">
										<input class="ace ace-switch ace-switch-7" type="checkbox" name="enabled" <#if model == null || model.enabled>checked="checked"</#if> <#if viewMode == "view">disabled</#if>>
										<span class="lbl"></span>
									</div>
								</div>
								<#if viewMode != "view">
								<div class="clearfix form-actions">
									<div class="col-md-offset-3 col-md-9">
										<button id="btnSubmit" class="btn btn-info" type="submit">
											<i class="fa fa-check bigger-110"></i>
											提 交
										</button>
									</div>
								</div>
								</#if>
							</div>
						</div>
					</div>
				</form>
			</div>	
		</div>
		<script type="text/javascript">
		var opts = {type: BMAP_NAVIGATION_CONTROL_SMALL};
		var center = new BMap.Point(106.42,26.35);
		var gc = new BMap.Geocoder();
		var startMap = new BMap.Map("startMap");
		startMap.addControl(new BMap.NavigationControl(opts)); 
		startMap.centerAndZoom(center,8);
		startMap.addEventListener('click', function(e){
			$('#startLon').val(e.point.lng);
			$('#startLat').val(e.point.lat);
			gc.getLocation(e.point, function(result){      
	             if (result){      
	                 $('#startName').val(result.address);
	             }      
			});
		});
		var endMap = new BMap.Map("endMap");
		endMap.addControl(new BMap.NavigationControl(opts)); 
		endMap.centerAndZoom(center,8);
		endMap.addEventListener('click', function(e){
			$('#endLon').val(e.point.lng);
			$('#endLat').val(e.point.lat);
			gc.getLocation(e.point, function(result){      
	             if (result){      
	                 $('#endName').val(result.address);
	             }      
			});
		});
		
		$(function(){
			$('.chosen-select').chosen();
			$('#txtStartRegionId').ligerComboBox({
				width:180,
				selectBoxWidth: 200,
        		selectBoxHeight: 200,
				initValue:'8',
				valueField:'regionId',
				valueFieldID:'parentId',
				textField:'regionName',
				treeLeafOnly:false,
				isShowCheckBox:false,
				tree:{
					url:'${base}/region/getTreeList',
				 	textFieldName:'regionName',
				 	idFieldName:'regionId',
				 	parentIDFieldName:'parentId',
				 	checkbox:false
				},
				onSelected:function(value,text){
					startMap.centerAndZoom(text,11);
				}
			});
			$('#txtEndRegionId').ligerComboBox({
				width:180,
				selectBoxWidth: 200,
        		selectBoxHeight: 200,
				initValue:'8',
				valueField:'regionId',
				valueFieldID:'parentId',
				textField:'regionName',
				treeLeafOnly:false,
				isShowCheckBox:false,
				tree:{
					url:'${base}/region/getTreeList',
				 	textFieldName:'regionName',
				 	idFieldName:'regionId',
				 	parentIDFieldName:'parentId',
				 	checkbox:false
				},
				onSelected:function(value,text){
					endMap.centerAndZoom(text,11);
				}
			});
			
			$('#form').validator();
		})
		</script>
	</body>
</html>